package metamodels;

import java.util.ArrayList;
import java.util.List;

import ocl.Opposite;

public class Reference extends Feature {

	private Identifier name, type;
	Multiplicity multiplicity;
	Opposite opposite;

	public Reference(Identifier identifier, Identifier identifier2,
			Multiplicity multiplicity, Opposite opposite) {
		this.name = identifier;
		this.type = identifier2;
		this.multiplicity = multiplicity;
		this.opposite = opposite;
	}

	@Override
	public String toString() {
		return "reference " + name + " : " + type + " " + multiplicity + " "
				+ opposite + ";";
	}

	@Override
	public List<? extends String> getIdentifiers() {
		List<String> list = new ArrayList<String>();
		list.add(name.toString());
		list.add(type.toString());
		if (opposite.getId() != null)
			list.add(opposite.getId().toString());
		return list;
	}
	
	@Override
	public List<? extends Identifier> getIdentifiers_() {
		List<Identifier> list = new ArrayList<Identifier>();
		list.add(name);
		list.add(type);
		if (opposite.getId() != null)
			list.add(opposite.getId());
		return list;
	}
	
	@Override
	public String getMapping() {
		return "(" + name.toString() + " |-> " + type.toString() + ")";
	}
}
